//
//  JPSettingOpinionVC.m
//  JPKY
//
//  Created by 吴俊杰 on 2016/11/15.
//  Copyright © 2016年 Vitas. All rights reserved.
//

#import "JPSettingOpinionVC.h"
#import "OpinionView.h"

@interface JPSettingOpinionVC () <UITableViewDataSource,UITableViewDelegate>

@end

@implementation JPSettingOpinionVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    [self setupSubviews];
}

#pragma mark - 界面初始化

/**
 初始化UI
 */
- (void)setupUI {
    
    UIBarButtonItem *commitBtn = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.rightBarButtonItem = commitBtn;
    
}

/**
 初始化子视图
 */
- (void)setupSubviews {
    
    //上方的意见视图
    OpinionView *opinionView = [[OpinionView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height * 0.4)];
    [self.view addSubview:opinionView];
    
    // 下方的选项视图
    UITableView *selectView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    [self.view addSubview:selectView];
    selectView.scrollEnabled = NO;
    //设置代理和数据源
    selectView.dataSource = self;
    selectView.delegate = self;
    
    [selectView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(opinionView.mas_bottom);
        make.width.equalTo(self.view);
        make.bottom.equalTo(self.view);
    }];
}

#pragma mark - UITableViewDatasource 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    
    if (indexPath.row == 0) {
        [cell.imageView setImage:[UIImage imageNamed:@"medtronic_phone"]];
        cell.textLabel.text = @"联系我们";
    } else if(indexPath.row == 1) {
        [cell.imageView setImage:[UIImage imageNamed:@"medtronic_service"]];
        cell.textLabel.text = @"用户交流群";
    }
    return cell;
}

#pragma mark - UITableViewDelegate 代理方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
